<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('调动审批')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-jobTransfer-edit" th:object="${entity}">
            <input name="jobTransferId" th:field="*{jobTransferId}" type="hidden">
            <input name="id" th:field="*{jobTransferId}" type="hidden">
            <input name="taskId" th:field="*{taskId}" type="hidden">
            <input type="hidden" name="p_COM_comment" />
            <div class="form-group" style="display: none">
                <label class="col-sm-3 control-label is-required">调动人id：</label>
                <div class="col-sm-8">
                    <input name="empId" th:field="*{empId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">调动人姓名：</label>
                <div class="col-sm-8">
                    <input name="empName" th:field="*{empName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">入职日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="nonManagerDate" th:value="${#dates.format(entity.nonManagerDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">现岗位id：</label>
                <div class="col-sm-8">
                    <!--<input name="currentPostId" th:field="*{currentPostId}" class="form-control" type="text" required>-->
                    <select id="currentPostId" name="currentPostId" class="form-control m-b" th:with="postAll=${@postService.getPostAll()}" required>
                        <option value="">请选择</option>
                        <option th:each="post : ${postAll}" th:text="${post.getPostName()}" th:value="${post.getPostId()}"  th:hidden="${post.getStatus() == '1'}" th:field="*{currentPostId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">现部门id：</label>
                <div class="col-sm-8">
                    <!--<input name="currentDeptId" th:field="*{currentDeptId}" class="form-control" type="text" required>-->
                    <select id="currentDeptId" name="currentDeptId" class="form-control m-b" th:with="deptAll=${@deptService.getDeptAll()}">
                        <option value="">请选择</option>
                        <option th:each="dept : ${deptAll}" th:text="${dept.getShowName()}" th:value="${dept.getDeptId()}" th:field="*{currentDeptId}"
                                th:hidden="${dept.getStatus() == '1' || dept.getDelFlag() != '0' }"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">调动岗位id：</label>
                <div class="col-sm-8">
                    <!--<input name="jobTransferPostId" th:field="*{jobTransferPostId}" class="form-control" type="text" required>-->
                    <select id="jobTransferPostId" name="jobTransferPostId" class="form-control m-b" th:with="postAll=${@postService.getPostAll()}" required>
                        <option value="">请选择</option>
                        <option th:each="post : ${postAll}" th:text="${post.getPostName()}" th:value="${post.getPostId()}"  th:hidden="${post.getStatus() == '1'}" th:field="*{jobTransferPostId}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">调动部门id：</label>
                <div class="col-sm-8">
                    <!--<input name="jobTransferDeptId" th:field="*{jobTransferDeptId}" class="form-control" type="text" required>-->
                    <select id="jobTransferDeptId" name="jobTransferDeptId" class="form-control m-b" th:with="deptAll=${@deptService.getDeptAll()}">
                        <option value="">请选择</option>
                        <option th:each="dept : ${deptAll}" th:text="${dept.getShowName()}" th:value="${dept.getDeptId()}" th:field="*{jobTransferDeptId}"
                                th:hidden="${dept.getStatus() == '1' || dept.getDelFlag() != '0' }"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">调动日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="jobTransferrDate" th:value="${#dates.format(entity.jobTransferrDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">调动原因：</label>
                <div class="col-sm-8">
                    <input name="jobTransferDescription" th:field="*{jobTransferDescription}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">调动类型：</label>
                <div class="col-sm-8">

                    <input name="jobTransferType" th:field="*{jobTransferType}" class="form-control" type="text" required>
                    <!--<div class="radio-box" th:each="dict : ${@dict.getType('sys_job_transfer')}">
                        <input type="radio" th:id="${'jobTransferType_' + dict.dictCode}" name="jobTransferType" th:value="${dict.dictValue}" th:field="*{jobTransferType}" required>
                        <label th:for="${'jobTransferType_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>-->
                </div>
            </div>

            <div th:replace="include/fileUploadUtil::fileUploadShow(${entity},'附件')" ></div>
           <!-- <div class="form-group">
                <label class="col-sm-3 control-label is-required">现领导意见：</label>
                <div class="col-sm-8">
                    <input name="currentDescription" th:field="*{currentDescription}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">调动领导意见：</label>
                <div class="col-sm-8">
                    <input name="transferDescription" th:field="*{transferDescription}" class="form-control" type="text">
                </div>
            </div>
-->

            <hr />
            <div class="form-group taskItem">
                <label class="col-sm-3 control-label" for="hrApproved">审批意见：</label>
                <div class="col-sm-8">
                    <select name="p_B_hrApproved" id="hrApproved" class="form-control m-b" required>
                        <option value="true">同意</option>
                        <option value="false">拒绝</option>
                    </select>
                </div>
            </div>
            <div class="form-group taskItem">
                <label class="col-sm-3 control-label">批注：</label>
                <div class="col-sm-8">
                    <textarea name="comment" class="form-control" ></textarea>
                </div>
            </div>

        </form>
    </div>

    <div class="container-div"  style="height: initial;">
        <div class="row">
            <div class="col-sm-12 search-collapse" hidden>
                <form id="role-form">
                    <input type="hidden" id="instanceId" name="instanceId" th:value="${entity.instanceId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                任务名称：<input type="text" name="activityName"/>
                            </li>
                            <li>
                                办理人ID：<input type="text" name="assignee"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('role-form' , 'bootstrap-table' )"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('role-form' , 'bootstrap-table')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table ">
                <table id="bootstrap-table" ></table>
            </div>
        </div>
    </div>

    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "hr/jobTransfer";
        $("#form-jobTransfer-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                if ($('textarea[name="comment"]').val()) {
                    $('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
                }
                var taskId = [[${taskId}]];
                $.operate.save(prefix + "/complete/" + taskId, $('#form-jobTransfer-edit').serialize());
            }
        }

        $("input[name='startTime']").datetimepicker({
            autoclose: true
        });

        $("input[name='endTime']").datetimepicker({
            autoclose: true
        });

        $(function () {

            $('select[name="type"]').prop('disabled', true);

            for (var i = 0; i < document.getElementsByTagName("select").length; i++) {
                var documentName =  document.getElementsByTagName("select")[i];
                if (documentName.id != "hrApproved") {
                    documentName.disabled = true;
                }
            }

            //审批意见
            debugger
            $.common.openTaskCommens($("#instanceId").val(),'role-form');
        });

    </script>
    <script th:inline="javascript">
        var prefixhistory = ctx + "process/general";
        for (var i = 0; i < document.getElementsByTagName("input").length; i++) {
            var inputDocument = document.getElementsByTagName("input")[i];
            if (inputDocument.name != 'activityName'
                && inputDocument.name != 'assignee'
                && inputDocument.name != 'jobTransferId'){
                inputDocument.disabled = true;
            }
        }
        for (var i = 0; i < document.getElementsByTagName("textarea").length; i++) {
            var textareaDocument = document.getElementsByTagName("textarea")[i];
            if (textareaDocument.name != 'comment'){
                textareaDocument.disabled = true;
            }
        }
        for (var i = 0; i < document.getElementsByTagName("select").length; i++) {
            var selectDocument = document.getElementsByTagName("select")[i];
            if (selectDocument.name != 'p_B_hrApproved'){
                selectDocument.disabled = true;
            }
        }

    </script>
</body>
</html>
